#include <regx52.h>

#define LED2  P2_1
unsigned char timer_0_count = 0;
unsigned char led_lux = 0;

void timer_0_isr() interrupt 1
{
	TL0 = 0xD2;				
	TH0 = 0xFF;
	if(timer_0_count++ == 20) 
	{
		timer_0_count = 0;
	}
	LED2 = timer_0_count >= led_lux;
}

void Timer0_Init()
{
	//AUXR &= 0x7F;		//12T
	TMOD &= 0xF0;			//
	TMOD |= 0x01;			//timer 0 mode 01  16bit no reload
	TL0 = 0xD2;				
	TH0 = 0xFF;		    //11.0592MHz  50us		
	TF0 = 0;  //clear timer 0 interrupt flag
	ET0 = 1;  //enable timer 0 interrupt
	EA  = 1;  //enable all interrupts
	TR0 = 1;  //timer 0 run
}